<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/element.css" rel="stylesheet"/>
    <link href="../css/styleindex.css" rel="stylesheet"/>
    <link href="../css/swiper.min.css" rel="stylesheet"/>
    <style>
    .layui-laydate{
      width: 100%!important;
    }.layui-laydate-main{
      width: 100%!important;
    }
    .layui-laydate-content table{
      width: 100%!important;
    }.el-table .cell{
      white-space:pre-line;
      text-align: center;
    }
    </style>
</head>
<body style="background:#EFF0F4;">

  <div class="mui-content">
    <div id="vm" class="x-examok" v-cloak>
      <div class="x-header-g" id="header">
        <a class="x-header-arrow" @click="api.closeWin()"></a>
        <div class="x-header-t">毛利分析</div>
      </div>
      <!--  -->
      <div class="x-trtali-box" id="calali" style="margin:1rem"></div>
      <!--  -->
      <div class="x-ut-top">
        <div class="x-inc-num">系统参与门店：<span class="x-inc-g">{{personnum}}个</span></div>
        <div class="x-inc-num">本组参与店面：<span class="x-inc-g">{{personnum2}}个</span></div>
      </div>
      <!--  -->
      <div class="x-margin-b">

        <el-table :data="tabledata">
            <el-table-column label="核算类别" width="" fixed>
              <template slot-scope="scope">
                {{scope.row.title}}
              </template>
            </el-table-column>
            <el-table-column :label="'当日毛利 \n 销售额/毛利/毛利率'" width="100">
              <template slot-scope="scope">
                {{scope.row.day_sale}}/{{scope.row.day_gross}}/{{scope.row.day_rate}}
              </template>
            </el-table-column>
            <el-table-column :label="'月累计毛利 \n 销售额/毛利/毛利率'" width="120">
              <template slot-scope="scope">
                {{scope.row.month_sale}}/{{scope.row.month_gross}}/{{scope.row.month_rate}}
              </template>
            </el-table-column>
            <el-table-column label="单品毛利" width="70">
              <template slot-scope="scope">
                <el-button type="text" @click="getdesctwo(scope.row.cateid,scope.row.title)">查看</el-button>
              </template>
            </el-table-column>
          </el-table>
      </div>
      <!--  -->
      <!--  -->
      <el-dialog :title="toasttitletwo" :visible.sync="dialogTableVisibletwo" width="90%">
        <el-table :data="tableDatatoasttwo">
          <el-table-column label="产品名称" width="" fixed>
            <template slot-scope="scope">
              {{scope.row.title}}
            </template>
          </el-table-column>
          <el-table-column label="当日毛利(销售额/毛利/毛利率" width="">
            <template slot-scope="scope">
              {{scope.row.day_sale}}/{{scope.row.day_gross}}/{{scope.row.day_rate}}
            </template>
          </el-table-column>
          <el-table-column label="月累计毛利(销售额/毛利/毛利率" width="">
            <template slot-scope="scope">
              {{scope.row.month_sale}}/{{scope.row.month_gross}}/{{scope.row.month_rate}}
            </template>
          </el-table-column>
        </el-table>
      </el-dialog>
    </div>
  </div>

  <script type="text/javascript" src="../script/vue.js"></script>
  <script type="text/javascript" src="../script/element.js"></script>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/base.js"></script>
  <script type="text/javascript" src="../script/swiper.min.js"></script>
  <script type="text/javascript" src="../script/laydate/laydate.js"></script>
	<script>
apiready = function () {
    $api.fixStatusBar($api.byId('header'));


    //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          tabsid:0,
          thmonth:'',
          tabsdata:'',
          curId:0,
          tabledata:[],
          personnum:0,
          personnum2:0,
          dialogTableVisibletwo:false,
          tableDatatoasttwo:[],
          toasttitletwo:'',

        }
      },
      created:function() {
        var that=this;


      },
      mounted:function(){
        var that=this;
        laydate.render({
          elem: '#calali',
          position: 'static',
          btns:['now'],
          format:'yyyyMMdd',
          // theme:'#058142',
          change:function(value,date){
            console.log(value);
            that.thmonth = value;
            that.getdata()
          }
        });
        //当前月份
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth()+1;
        var day = date.getDate()
        if(month<10){
          month = '' + 0 + month;
        }
        if(day<10){
          day = '' + 0 + day;
        }
        var toMonth = '' + year +  month +  day;
        that.thmonth = toMonth;
        that.personnum = $api.getStorage('syscount');
        that.personnum2 = $api.getStorage('groupcount');
        that.getdata()
      },
      methods: {
        getdata:function(){
            let that=this;
            api.ajax({
                url:baseurl+'api/material/grossList',
                methods:'get',
                data:{
                    values:{
                        sec: $api.getStorage('apptoken'),
                        date:that.thmonth,
                        _ssid:$api.getStorage('jobid')
                    }
                }
            },function(ret,err){
                if(ret){
                api.hideProgress();
                console.log(JSON.stringify(ret));
                if(ret.status == 1){
                    that.tabledata = ret.data.list;

                }else{
                    api.toast({
                        msg: ret.msg,
                        duration: 3000,
                        location: 'bottom'
                    });
                }
                }else{
                api.hideProgress();
                console.log(JSON.stringify(err));
                api.toast({
                    msg: err.msg,
                    duration: 3000,
                    location: 'bottom'
                });
                }
            })
        },
        getdesctwo:function(id,title){
          let that=this;
          that.dialogTableVisibletwo = true;
          that.toasttitletwo = title;
          api.ajax({
            url:baseurl+'api/material/grossAssetsList',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.thmonth,
                cateid:id,
                _ssid:$api.getStorage('jobid')
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.tableDatatoasttwo = ret.data.list;

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
      }
    })
	}


	</script>
</body>
</html>
